<template>
  <div class="tabbar_item" @click="itemClick">
    <div v-if="ifShow" class="tabbar_item_img">
      <slot name="img_active"></slot>
    </div>
    <div v-else class="tabbar_item_img">
      <slot name="img_normal"></slot>
    </div>
    <div :class="ifShow?'tabbar_item_text_active':'tabbar_item_text_normal'">
      <slot name="item_text"></slot>
    </div>
  </div>
</template>
<script>
export default {
  name: "TabBarItem",
  props: {
    path: {
      type: String,
      default: ""
    }
  },
  methods: {
    itemClick() {
      // console.log("router=route=区分", this.$router, this.$route);
      // this.$router整个路由对象，包括对路由跳转等的操作
      // this.$route包含当前路由的信息对象
      this.$router.push(this.path);
    }
  },
  computed: {
    ifShow() {
      return this.$route.path.indexOf(this.path) > -1;
    }
  }
};
</script>
<style scoped>
.tabbar_item {
  flex: 1;
  text-align: center;
  height: 49px;
  font-size: 14px;
}
.tabbar_item_text_normal {
  margin-top: -3px;
}
.tabbar_item_text_active {
  margin-top: -3px;
  color: red;
}
</style>